//
//  JLViewController.swift
//  Chain
//
//  Created by Jiang Chencheng on 2024/8/16.
//

import Foundation
import UIKit
import JLCommonKit
import JLLogger

open class JLViewController: UIViewController {
    
    open private(set) var isFirstLoad: Bool = true
    
    deinit {
        JLLogger.info("\(typeName) Has Been Destoried")
    }

}


extension JLViewController: TypeNameable {}


// MARK: - Override
extension JLViewController {
    
    override open func viewDidLoad() {
        super.viewDidLoad()
        setup()
    }
    
    override open func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        JLLogger.info("\(typeName) willAppear")
    }
    
    override open func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        isFirstLoad = false
    }

    override open func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        if parent?.isMember(of: JLViewController.self) ?? false { return }
        JLLogger.info("\(typeName) willDisappear")
    }

}


// MARK: - Private

private extension JLViewController {
    func setup() {
        view.backgroundColor = .white
    }
}
